package UIPackage;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import Sistem.Register;
//VS4E -- DO NOT REMOVE THIS LINE!
public class UcusOlusturmaKargoPilotGUI extends JFrame {

	private static final long serialVersionUID = 1L;
	private Register r;
	private JLabel jLabel0;
	private JButton jButton0;
	private JLabel jLabel1;
	private JComboBox jComboBox0;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public UcusOlusturmaKargoPilotGUI(Register r){
		this.r=r;
		initComponents();
		for (String p: r.getPilotList())
			jComboBox0.addItem(p);
	}
	public UcusOlusturmaKargoPilotGUI() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJLabel0(), new Constraints(new Leading(136, 10, 10), new Leading(43, 10, 10)));
		add(getJLabel1(), new Constraints(new Leading(43, 10, 10), new Leading(103, 10, 10)));
		add(getJButton0(), new Constraints(new Leading(92, 10, 10), new Leading(160, 10, 10)));
		add(getJComboBox0(), new Constraints(new Leading(158, 112, 10, 10), new Leading(99, 12, 12)));
		setSize(320, 240);
	}
	private JComboBox getJComboBox0() {
		if (jComboBox0 == null) {
			jComboBox0 = new JComboBox();
			jComboBox0.setModel(new DefaultComboBoxModel(new Object[] { }));
			jComboBox0.setDoubleBuffered(false);
			jComboBox0.setBorder(null);
		}
		return jComboBox0;
	}
	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("Pilot Listesi");
		}
		return jLabel1;
	}
	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Tamam");
			jButton0.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton0MouseMouseClicked(event);
				}
			});
		}
		return jButton0;
	}
	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setText("Pilot Seçme");
		}
		return jLabel0;
	}
	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				UcusOlusturmaKargoPilotGUI frame = new UcusOlusturmaKargoPilotGUI();
				frame.setDefaultCloseOperation(UcusOlusturmaKargoPilotGUI.EXIT_ON_CLOSE);
				frame.setTitle("UcusOlusturmaYolcuPilotGUI");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}
	private void jButton0MouseMouseClicked(MouseEvent event) {
		r.kargoPilotBelirle(jComboBox0.getSelectedIndex());
		UcusOlusturmaKargoOnayGUI form = new UcusOlusturmaKargoOnayGUI(r);
		this.hide();
		form.show();
	}

}
